import axios from 'axios';

let base = 'http://localhost:5000';
let config = {
    headers:{'Content-Type':'multipart/form-data'}
};  //添加请求头

//登录
export const requestLogin = params => { return axios.post(`${base}/users/login`, params).then(res => res.data); };

/**
 * 新增部门
 * @param params
 * @returns {Promise.<TResult>}
 */
export const addDepartment = params => { return axios.post(`${base}/departments/adddepartment`, params).then(res => res.data); };

/**
 * 更新部门信息
 * @param params
 * @returns {Promise.<TResult>}
 */
export const editDepartment = params => { return axios.post(`${base}/departments/updatedepartment`, params).then(res => res.data); };

/**
 * 获取部门列表
 * @param params
 * @returns {Promise.<TResult>}
 */
export const getDepartmentList = params => { return axios.post(`${base}/departments/departmentlist`, params).then(res => res.data); };

/**
 * 获取所有部门列表
 * @param params
 * @returns {Promise.<TResult>}
 */
export const getAllDepartmentList = params => { return axios.get(`${base}/departments/getalldepartmentlist`).then(res => res.data); };


/**
 * 删除部门
 * @param params
 * @returns {Promise.<TResult>}
 */
export const removeDepartment = params => { return axios.post(`${base}/departments/deletedepartment`, params).then(res => res.data); };

/**
 * 批量删除部门
 * @param params
 * @returns {Promise.<TResult>}
 */
export const batchRemoveDepartment = params => { return axios.post(`${base}/departments/deletedepartment`, params).then(res => res.data); };


/**
 * 获取用户列表
 * @param params
 * @returns {Promise.<TResult>}
 */
export const getUserList = params => { return axios.post(`${base}/users/userlist`, params).then(res => res.data); };

/**
 * 新增用户登录
 * @param params
 * @returns {Promise.<TResult>}
 */

export const addUser = params => { return axios.post(`${base}/users/adduser`, params,config).then(res => res.data); };

/**
 * 编辑用户登录
 * @param params
 * @returns {Promise.<TResult>}
 */
export const editUser = params => { return axios.post(`${base}/users/updateuser`, params,config).then(res => res.data); };


/**
 * 删除用户
 * @param params
 * @returns {Promise.<TResult>}
 */
export const removeUser = params => { return axios.post(`${base}/users/deleteuser`, params).then(res => res.data); };

